package com.itheima.health.dao;

import com.github.pagehelper.Page;
import com.itheima.health.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @package：com.itheima.health.dao
 * @Author: mint
 * @Date: 2024/7/13 17:07
 */
public interface SetmealDao {
    @Select("select * from t_setmeal;")
    List<Setmeal> findAll();

    @Select("select * from t_setmeal where id = #{id};")
    Setmeal findFullSetmealById(Integer id);

    Page<Setmeal> findPage(String queryString);

    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{setmealId}")
    List<Integer> findCheckGroupIds(Integer setmealId);

    @Insert("insert into t_setmeal values (null, #{name}, #{code}, #{helpCode}, #{sex}, #{age}, #{price}, #{remark}, #{attention}, #{img});")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void add(Setmeal setmeal);
    void addCheckGroupId(Integer id, Integer[] checkgroupIds);
    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void deleteAssociatuon(Integer id);


    void update(Setmeal setmeal);
    @Delete("delete from t_setmeal where id = #{id}")
    void deleteById(Integer id);

    @Select("select name from t_setmeal where id = #{setmealId};")
    String findNameById(Integer setmealId);
}
